#!/usr/bin/perl
#
$senNum=1;
while($line=<STDIN>) {
	chomp($line);
	@links = split(/\s+/,$line);
	my(%senLinks) = ();
	foreach $line (@links) {
		($src,$tgt) = split(/-/,$line);
		push(@{$senLinks{$src}},$tgt);
	}	

	foreach $src (sort {$a<=>$b} %senLinks) {
		foreach $tgt (@{$senLinks{$src}}) {
			print $senNum."\t".$src."\t".$tgt."\n";
		}
	}
	$senNum++;
}
